package net.huashitong.supervision.task.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.supervision.task.entity.ReadDocDraft;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author ling
 * @date: 2020/2/10
 * @time: 10:22
 * @version: 1.0
 * @Description:
 */
@Repository
public class ReadDocDraftDao extends StringDao<ReadDocDraft> {
    public List<ReadDocDraft> queryList(ReadDocDraft draft) {
        GenericQuery obj = createQuery("obj");
        obj.append(" and userId =:userId").setParam("userId",draft.getCreateUserId());
        if (StringUtils.isNotBlank(draft.getTitle())){
            obj.append(" and title like:title").setParam("title",StringUtils.getLikewords(draft.getTitle()));
        }
        if (StringUtils.isNotBlank(draft.getContent())){
            obj.append(" and content like:content").setParam("content",StringUtils.getLikewords(draft.getContent()));
        }
        return obj.listResult();
    }
}
